package com.animation_study.mpandroidchart.fragment;

import com.animation_study.R;
import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;

import java.util.ArrayList;

/**
 * 柱状图
 * Created by css on 2017/12/25.
 */

public class BarFragment extends BaseFragment {
    private BarChart bar_chart;

    @Override
    public int getLayout() {
        return R.layout.fragment_bar;
    }

    @Override
    protected void initView() {
        ArrayList<BarEntry> entries = new ArrayList<>();
        ArrayList<String> lable = new ArrayList<>();
        bar_chart = rootView.findViewById(R.id.bar_chart);

        for (int i = 1; i <= 12; i++) {
            lable.add(i + "次");
            entries.add(new BarEntry(i, i));
        }

        BarDataSet barDataSet = new BarDataSet(entries, "柱状图学习");
        BarData barData = new BarData(lable, barDataSet);
        bar_chart.setData(barData);

    }
}
